home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
DIO.H
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-25
|
9KB
|
354 lines
#ifndef _DIO_H_
#define _DIO_H_
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: data.h
// Title: Data File I/O Library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module is the primary header file for the data file library.
//
// Characteristics of data files:
// All logical files start on a 512 byte boundary.
// Each file has 32 flag bits. The upper 16 are for internal use. The
// lower 16 may be user defined.
// Each physical file has a user data area
// Each logical file has a user data area
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <base.h>
//----------------------------------------------------------------------------
// Miscellaneous constants
//----------------------------------------------------------------------------
#define MAX_PHYSICAL_FILES (8) // Maximum opened physical files
#define MAX_PHYSICAL_NAME (80) // Maximum length of physical file
#define MAX_PHYSICAL_APP_ID (4) // Maximum length of physical file
// internal name
#define MAX_LOGICAL_FILES (32) // Maximum opened logical files
#define MAX_LOGICAL_NAME (32) // Maximum length of logical file name
// Maximum name length "physical~logical"
#define MAX_DIO_NAME (MAX_PHYSICAL_NAME+MAX_LOGICAL_NAME+1)
#define MAX_HEADER_USER (128) // User area size (header)
#define MAX_DATA_USER (64) // User area size (data)
#define MAX_BLOCK_SIZE (8 _K)
typedef int HPF; // hpf, Physical file handle
BASETYPE(HPF);
typedef int HLF; // hlf, Logical file handle
BASETYPE(HLF);
enum DATADIR_TYPE // Data file types
{
DFT_RANDOM = 0, // Random access data -- default
DFT_DELETED, // File has been deleted
DFT_BLOCK, // Generic blocked data
DFT_ISAM_DATA, // ISAM blocked data
DFT_ISAM0, // ISAM index - level 0
DFT_ISAM1, // ISAM index - level 1
DFT_ISAM2, // ISAM index - level 2
DFT_ISAM3, // ISAM index - level 3
DFT_ISAM4, // ISAM index - level 4
DFT_ISAM5, // ISAM index - level 5
DFT_ISAM6, // ISAM index - level 6
DFT_ISAM7, // ISAM index - level 7
DFT_ISAM8, // ISAM index - level 8
DFT_ISAM9, // ISAM index - level 9
DFT_ISAMA, // ISAM index - level 10
DFT_ISAMB, // ISAM index - level 11
DFT_ISAMC, // ISAM index - level 12
DFT_ISAMD, // ISAM index - level 13
DFT_ISAME, // ISAM index - level 14
DFT_ISAMF, // ISAM index - level 15
DFT_ISAM_RECNO, // ISAM record number index
DFT_MAX,
};
//
// This is a pointer to a function used by the isam indexing routine.
// This function is passed a pointer to the current block,
// the size of the current block, a pointer to a buffer
// to place a key into, and a pointer to a variable to place
// the size of the key into.
// This function should generate a key for the first record in the block
// and place it in the buffer. The size of the key should be placed in the
// variable which is provided.
// Function should return TRUE if successful.
// Key size is limited to ISAM_KEY_LEN bytes in length.
// This routine is called an extra time at initialization and termination.
// The block pointer is null at these times. The block size is 0 at start up
// and 1 at termination.
//
#define ISAM_MAX_LEVEL (16) // Maximum isam levels
#define ISAM_KEY_LEN (256) // Maximum index key length
#define ISAM_START (-1) // Start record code
#define ISAM_END (-2) // End record code
typedef struct DI_INDEX
{
LONG lBlock; // Block #, 0..n-1 or special
PBYTE pbBlock; // Pointer to block
SIZET cbBlock; // Size of block in bytes
PBYTE pbKey; // Pointer to key buffer
SIZET cbKey; // Size of key (set by user)
} DI_INDEX;
BASETYPE(DI_INDEX);
typedef BOOL (FN_E *PFNINDEX)(PDI_INDEX);
//
// Macro to convert a physical file handle in a logical file name.
//
#define HPF2PCSZ(x) ((PCSZ)US2P(x))
//
// This is the data structure written to the user data area of
// a logical file by the file compressor.
//
typedef struct _DA_COMPRESS_USER // Structure written by compressor
{ // into user data area
LONG lRecs; // Total compressed records
LONG lBytes; // Total compressed bytes
LONG lSlack; // Slack bytes
LONG lBlocks; // Total compressed blocks
} DA_COMPRESS_USER;
BASETYPE(DA_COMPRESS_USER);
//
// This is the record ID structure. It is equivalent to
// 2 ushorts stored in a long.
//
typedef struct RECID
{
LONG lBlock;
USHORT usOffset;
} RECID;
BASETYPE(RECID);
typedef struct DIOTYPE
{
USHORT usType;
PSZ pszShort;
PSZ pszLong;
} DIOTYPE;
extern DIOTYPE adiotype[];
//----------------------------------------------------------------------------
// Prototypes
//----------------------------------------------------------------------------
#if COMPILE_CPP
extern "C"
{
#endif
//
// diappend.c
//
BOOL FN_E DioAppend(PCSZ, PCSZ, USHORT, USHORT, PHF, PBOOL);
BOOL FN_E DioAppendClose(BOOL, BOOL);
BOOL FN_E DioAppendFile(PCSZ, PCSZ, USHORT, USHORT, PCSZ);
//
// dicache.c
//
BOOL FN_E DioCacheRelease(HLF);
BOOL FN_E DioCacheSet(HLF, SIZET);
//
// dichk.c
//
BOOL FN_E DioCheck(PCSZ);
//
// diclose.c
//
BOOL FN_E DioCloseAll(void);
BOOL FN_E DioCloseLogical(HLF);
BOOL FN_E DioClosePhysical(HPF);
BOOL FN_E DioRelease(void);
//
// dicopy.c
//
BOOL FN_E DioCopy(PCSZ, PCSZ, PCSZ, PCSZ, USHORT);
//
// dicrc.c
//
BOOL FN_E DioCrc(PCSZ, PCSZ, USHORT, PCRC);
//
// dicreate.c
//
BOOL FN_E DioCreate(PCSZ, PCSZ, PCSZ, USHORT);
//
// didata.c
//
BOOL FN_E DioSetDataPath(PCSZ);
//
// didelete.c
//
BOOL FN_E DioDelete(PCSZ, PCSZ, USHORT);
//
// diextrac.c
//
BOOL FN_E DioExtract(HLF, PCSZ);
BOOL FN_E DioExtractFile(PCSZ, PCSZ, USHORT, PCSZ);
//
// diflush.c
//
BOOL FN_E DioFlush(void);
//
// diindex.c
//
BOOL FN_E DioIndex(PCSZ, PCSZ, PFNINDEX, USHORT);
//
// diinfo.c
//
BOOL FN_E DioGetBlocks(HLF, PLONG);
BOOL FN_E DioGetBlockSize(HLF, PUSHORT);
BOOL FN_E DioGetFlags(HLF, PFLAG32);
BOOL FN_E DioGetRecords(HLF, PLONG);
BOOL FN_E DioGetSize(HLF, PFPOS);
BOOL FN_E DioGetUser(HLF, PBYTE, SIZET);
BOOL FN_E DioGetVersion(HLF, PUSHORT);
BOOL FN_E DioHeaderGetFlags(HPF, PFLAG32);
BOOL FN_E DioHeaderGetUser(HPF, PBYTE, SIZET);
BOOL FN_E DioHeaderGetVersion(HPF, PUSHORT);
BOOL FN_E DioHeaderSetFlags(HPF, FLAG32);
BOOL FN_E DioHeaderSetUser(HPF, PBYTE, SIZET);
BOOL FN_E DioHeaderSetVersion(HPF, USHORT);
BOOL FN_E DioSetFlags(HLF, FLAG32);
BOOL FN_E DioSetUser(HLF, PBYTE, SIZET);
BOOL FN_E DioSetVersion(HLF, USHORT);
//
// dimisc.c
//
BOOL FN_E DioIsDataFile(PCSZ, PCSZ);
BOOL FN_E DioIsEof(HLF);
BOOL FN_E DioIsError(HLF);
BOOL FN_E DioIsLogicalFile(PCSZ, USHORT);
BOOL FN_E DioIsValid(HLF);
//
// diopen.c
//
BOOL FN_E DioOpenAllPhysical(PCSZ, BOOL);
BOOL FN_E DioOpenIndex(PCSZ, PHLF);
BOOL FN_E DioOpenLogical(PCSZ, PHLF, USHORT);
BOOL FN_E DioOpenPhysical(PCSZ, PHPF, BOOL);
//
// diread.c
//
BOOL FN_E DioRead(HLF, PBYTE, SIZET, PSIZET);
BOOL FN_E DioReadBlock(HLF, PBYTE, PBYTE _FAR_ *, PLONG);
BOOL FN_E DioReadFirst(HLF, PBYTE, SIZET, PBYTE, PBYTE _FAR_ *, PLONG);
BOOL FN_E DioReadIndex(HLF, PBYTE, SIZET, PLONG);
//
// direcno.c
//
BOOL FN_E DioOpenRecNo(PCSZ, PHLF);
BOOL FN_E DioRecNo2RecId(HLF, LONG, PRECID);
BOOL FN_E DioRecId2RecNo(HLF, PLONG, PRECID);
//
// diseek.c
//
BOOL FN_E DioSeek(HLF, FPOS);
BOOL FN_E DioSeekBlock(HLF, LONG);
//
// dishow.c
//
BOOL FN_E DioShow(PCSZ, BOOL);
//
// diupdate.c
//
BOOL FN_E DioUpdate(PCSZ, PCSZ, USHORT, PCSZ);
//
// diwrite.c
//
BOOL FN_E DioWrite(HLF, PBYTE, SIZET, PSIZET);
BOOL FN_E DioWriteBlock(HLF, PBYTE);
BOOL FN_E DioWriteUpdate(HLF);
#if COMPILE_CPP
}
#endif
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------
#endif // _DIO_H_